#include<bits/stdc++.h>
using namespace std;
int T,n,m,l,V,d,v,a,p,ans;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int i=1;i<=T;i++)
    {
        cin>>n>>m>>l>>V;
        for(int j=1;j<=n-1;j++)
        {
            cin>>d>>v>>a;
        }
        for(int k=1;k<=m;k++)
        {
            cin>>p;
        }
        cout<<n/2+1<<" "<<n/2+1<<endl;
    }
    return 0;
}
